package com.yml.mall.config;

import com.yml.mall.interceptor.MyInterceptor;
import com.yml.mall.interceptor.PathParamInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName InterceptorConfig
 * @Author Administrator
 * @Date 2020/4/7   16:54
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //配置登录验证
        registry.addInterceptor(new MyInterceptor()).addPathPatterns("/user/**","/user",
                "/carts/**","/carts", "/shippings/**","/shippings")
                .excludePathPatterns("/user/register","/user/login");
        registry.addInterceptor(new PathParamInterceptor()).addPathPatterns("/category/*");

    }
}
